<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><?php echo $title;?></title>
<style type="text/css">
    .prtext {
    color: #000000;
    font-family: arial;
    font-size: 14px;
    }
    .prhead {
    color: #000000;
    font-family: arial;
    font-size: 18px;
    }
    .prhead_tnr {
    color: #000000;
    font-family: Times New Roman;
    }
    .prtext_blacksmall {
	font-size: 14px;
	color: #00000;
	font-family: arial;
    }
    .prtitle {
	font-size: 19px;
	color: #000000;
	font-family: arial;
	font-weight: bold;
    }
</style>
</head>
<body onload="window.print()">

<table width="800" cellspacing="0" cellpadding="0" border="0" align="center">
    <tbody>
      <tr>
       <td class="prtext">
        <table cellspacing="0" cellpadding="0" border="0">
          <tbody>
           <tr>
            <td width="90" valign="top"><img src="<?php echo site_url('images/r4.jpg') ?>" width="110px"></td>
            <td width="710" valign="top" class="prhead_tnr" align="left">
              <div align="center" style="font-size: 20px; margin-left: 5px; margin-top: 15px"><b>KEMENTERIAN AGAMA</b></div>
              <div align="center" style="font-size: 22px; margin-left: 5px; margin-top: 5px"><b>INSTITUT AGAMA ISLAM NEGERI (IAIN) MATARAM</b></div>
              <div align="center" style="font-size: 16px; margin-left: 5px; margin-top: 5px">Jalan Pendidikan No. 35 Telp. (0370) 621298 - 625337 - Fax. 625337</div>
              <br>
            </td>
           </tr>
           <tr>
            <td colspan="2"><hr color="#000000" size="5" /></td>
           </tr>
          </tbody>
        </table>
        <br><br><br /><?php $viewKontrolData = $this->system_model->getViewKontrolData($this->session->userdata('siamunp_user_prodi')); ?>
        <div align="center" class="prtitle">JADWAL KULIAH SEMESTER <?php echo strtoupper($viewKontrolData->SEMESTER)?> <?php echo $viewKontrolData->TAHUN_AJARAN ?></div>
        <br><br>
        <table cellspacing="1" cellpadding="2" border="0">
          <tbody>
            <tr class="prtext">
              <td width="50"><b>Nama</b></td>
              <td width="350">: <?php echo $this->session->userdata('siamunp_user_nama') ?></td>
            </tr>
            <tr class="prtext">
              <td><b>NIM</b></td>
              <td>: <?php echo $this->session->userdata('siamunp_user_nim') ?></td>
            </tr>
          </tbody>
        </table>
        <br />
        <table cellspacing="0"  bordercolor="#000000" cellpadding="4" border="1" style="border: solid 1.5pt black; border-collapse: collapse">
          <tbody>
            <tr bgcolor="#FFFFFF" align="center" class="prtext_blacksmall">
              <th style="border-bottom: solid 1.5pt black" width="70" height="43"><b>HARI</b></th>
              <th style="border-bottom: solid 1.5pt black" width="150"><b>JAM</b></th>
              <th style="border-bottom: solid 1.5pt black" width="90">KODE MK</th>
              <th style="border-bottom: solid 1.5pt black" width="210"><b>NAMA MK</b></th>
              <th style="border-bottom: solid 1.5pt black" width="40"><b>SKS</b></th>
              <th style="border-bottom: solid 1.5pt black" width="60"><b>KELAS</b></th>
              <th style="border-bottom: solid 1.5pt black" width="60"><b>RUANG</b></th>
              <th style="border-bottom: solid 1.5pt black" width="250">DOSEN PENGAMPU</th>
            </tr>
            <?php foreach($hari as $day): //Foreach Hari ?>

                     <?php $total_row = 0; ?>

                     <?php $dataJadwalKuliah = $this->sirak_akad_model->getJadwalKuliahByIdHari($day->ID,$this->session->userdata('siamunp_user_prodi'),$viewKontrolData->KODE_SEMESTER,$viewKontrolData->KODE_TAHUN,0); ?>

                     <?php if($dataJadwalKuliah): ?>
                            <?php $rowspan = TRUE; ?>

                            <?php foreach($dataJadwalKuliah as $jadwal): ?>
                                    <?php $dataKrs = $this->akad_model->getViewKrsAll($this->session->userdata('siamunp_user'),$viewKontrolData->KODE_TAHUN,$viewKontrolData->KODE_SEMESTER); ?>
                                    <?php if($dataKrs): ?>
                                            <?php foreach($dataKrs as $krs): ?>
                                                    <?php if($jadwal->KODE_MK == $krs->KODE_MK && $jadwal->KELAS == $krs->KELAS): ?>
                                                           <?php $total_row++; ?>
                                                    <?php endif ?>
                                            <?php endforeach ?>
                                    <?php endif ?>

                            <?php endforeach ?>

                            <?php $no_duplicate = 0 ?>
                            <?php foreach($dataJadwalKuliah as $jadwal): ?>
                                    <?php $dataKrs = $this->akad_model->getViewKrsAll($this->session->userdata('siamunp_user'),$viewKontrolData->KODE_TAHUN,$viewKontrolData->KODE_SEMESTER); ?>
                                    <?php if($dataKrs): ?>
                                           <?php foreach($dataKrs as $krs): ?>
                                                    <?php if($jadwal->KODE_MK == $krs->KODE_MK && $jadwal->KELAS == $krs->KELAS): ?>
                                                           <tr align="center">
                                                           <?php if($rowspan): ?>
                                                                  <td rowspan="<?php echo $total_row ?>"><?php echo ucwords(strtolower($day->NAMA_HARI)) ?></td>
                                                                  <?php $rowspan = FALSE; ?>
                                                           <?php endif; ?>

                                                           <td><?php echo substr($jadwal->MULAI, 0, 5) ?> - <?php echo substr($jadwal->SELESAI, 0, 5) ?></td>
                                                           <td><?php echo strtoupper($jadwal->KODE_MK) ?></td>
                                                           <td align="left" style="padding-left:10px"><?php echo $jadwal->NAMA_MK ?></td>
                                                           <td><?php echo $jadwal->SKS ?></td>
                                                           <td><?php echo $jadwal->KELAS ?></td>
                                                           <td><?php echo $jadwal->RUANG ?></td>
                                                           <td align="left" style="padding-left:10px"><?php echo $jadwal->NAMA_DOSEN ?><?php echo ($jadwal->GELAR_DOSEN)? ', '.$jadwal->GELAR_DOSEN:'' ?></td>
                                                           </tr>
                                                    <?php endif ?>
                                           <?php endforeach ?>
                                     <?php endif ?>
                                     <?php if($total_row == 0 && $no_duplicate == 0): ?>
                                           <tr align="center">
                                             <td><?php echo ucwords(strtolower($day->NAMA_HARI)) ?></td>
                                             <td align="left" colspan="7">-</td>
                                           </tr>
                                     <?php endif ?>
                            <?php $no_duplicate++ ?>
                            <?php endforeach; ?>
                     <?php elseif($total_row == 0): ?>
                           <tr align="center">
                             <td><?php echo ucwords(strtolower($day->NAMA_HARI)) ?></td>
                             <td align="left" colspan="7">-</td>
                           </tr>
                     <?php endif ?>

            <?php endforeach; ?>
          </tbody>
        </table>
       </td>
      </tr>
    </tbody>
  </table>
</body>
</html>